<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('category_id')->comment('分类ID');
            // 文章封面
            $table->string('cover')->nullable()->comment('文章封面');

            $table->string('title')->nullable()->comment('文章标题');
            $table->string('keywords')->nullable()->comment('文章关键词');
            $table->text('description')->nullable()->comment('文章描述');

            $table->text('content')->nullable()->comment('文章内容');
            $table->text('markdown')->nullable()->comment('文章Markdown内容');

            $table->boolean('is_top')->default(false)->comment('是否置顶');
            $table->boolean('is_recommend')->default(false)->comment('是否推荐');
            $table->integer('status')->default(0)->comment('文章状态 0=草稿 1=已发布 2=已下架');
            $table->integer('sort')->default(0)->comment('排序');

            // 推送状态 0=未推送 1=已推送
            $table->integer('push_status')->default(0)->comment('推送状态 0=未推送 1=已推送');
            $table->datetime('push_time')->nullable()->comment('推送时间');

            // 发布时间
            $table->datetime('published_at')->nullable()->comment('发布时间');

            $table->string('author')->nullable()->comment('作者');
            $table->unsignedBigInteger('views')->default(0)->comment('阅读量');
            $table->string('source')->nullable()->comment('文章来源');

            $table->timestamps();
            $table->comment('文章表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('articles');
    }
};
